import request from "@/utils/request"

enum API {
    ALLUSER_URL = '/admin/acl/user/',
    ADDUSER_URL = '/admin/acl/user/save',
    UPDATEUSER_URL = '/admin/acl/user/update',
    ALLROLE_URL = '/admin/acl/user/toAssign/',
    SETROLE_URL = '/admin/acl/user/doAssignRole',
    DELETEUSER_URL = '/admin/acl/user/remove/',
    DELETESOMEUSER_URL = '/admin/acl/user/batchRemove'
}

export const reqUser = (page, size,username) => request.get(API.ALLUSER_URL + `${page}/${size}/?username=${username}`)

export const reqAddOrUpdateUser = (data) => {
    if (data.id) {
        return request.put(API.UPDATEUSER_URL, data)
    } else {
        return request.post(API.ADDUSER_URL, data)
    }
}

export const reqAllRole = (userId) => request.get(API.ALLROLE_URL + userId)

export const reqSetUserRole = (data) => request.post(API.SETROLE_URL, data)

export const reqDeleteUser = (userId) => request.delete(API.DELETEUSER_URL + userId)

export const reqDeleteSomeUser = (idList) => request.delete(API.DELETESOMEUSER_URL, { data: idList })